<?php
my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('data_setting', false);
my_component_load('jabatan_description', false);
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id= isset( $_GET['id'] ) ? $_GET['id']:  0;
$jabatan_id= isset( $_GET['jabatan_id'] ) ? $_GET['jabatan_id']:  0;
$modulname = "Admin _BN_ Konfigurasi Data _BN_ Job Description";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){ 
		case   "page" :
			$validatepost = form_jabatan_description_validate($jabatan_id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_jabatan_description_create($jabatan_id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_jabatan_description_submit($jabatan_id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			break;
		case   "tanggung_jawab_page" :
			$validatepost = form_tanggung_jawab_validate($jabatan_id,$id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_tanggung_jawab_create($jabatan_id,$id);
				generate_my_web($content,"","plain.php");
				exit;
			}else{
				form_tanggung_jawab_submit($jabatan_id,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			my_direct('index.php?com=jabatan_description&task=list_tanggungjawab&jabatan_id='.$jabatan_id);			
			break;				
	}	 

else: 
	if($task == 'page'){
		$content  = form_jabatan_description_create($jabatan_id);
		generate_my_web($content,"","plain.php");
		exit; 	
	}elseif($task =='edit'){
		$pagename= "Perubahan Data";
		facebox_page('index.php?com=jabatan_description&task=page&jabatan_id='.$jabatan_id , $pagename , 260	); 			
	}elseif($task =='list_tanggung_jawab'){
		$pagename = $modulname;
		$pagename .= " _BN_ Tanggung Jawab";
		load_facebox_script();
		$view =  list_tanggung_jawab($jabatan_id);
		generate_my_web($view, $pagename );	
	}elseif($task =='tanggung_jawab_create'){
		$pagename= "...";
		facebox_page('index.php?com=jabatan_description&task=tanggung_jawab_page&jabatan_id='.$jabatan_id.'&id='.$id  , $title , 260	); 
	}elseif($task == 'tanggung_jawab_page'){
		$content  = form_tanggung_jawab_create($jabatan_id , $id);
		generate_my_web($content,"","plain.php");
		exit; 	
	}elseif($task == "tanggung_jawab_delete"){ 
		delete_tanggung_jawab($id);
		my_direct($_SERVER['HTTP_REFERER']);
	}else{
		$pagename ="Job Description";
		load_facebox_script();	
		$view = list_jabatan_description();
		$href= '';
		$content = spliter_browser( $view , $pagename ,$href);
		generate_my_web($content, $modulname );
	}
endif;  

?>